<?php
  include_once './lib/fun.php';
  if (checkLogin()) {
      $goodsId = isset($_GET['id']) && is_numeric($_GET['id'])?intval($_GET['id']):'';
      if ($goodsId) {
          mysqlInit('127.0.0.1', 'root', 'root', 'mall');
          $sql = "SELECT `id` from `mall_goods` WHERE `id`='{$goodsId}'";
          $res = mysql_query($sql);
          if (mysql_fetch_assoc($res)) {
              unset($sql,$res);
              $sql = "DELETE FROM `mall_goods` WHERE `id`='{$goodsId}'";
              $result = mysql_query($sql);
              if ($result) {
                  toMsgPage(1, '删除成功', 'index.php');
              } else {
                  toMsgPage(2, mysql_error());
              }
          } else {
              toMsgPage(2, '不存在该商品', 'index.php');
          }
      } else {
          toMsgPage(2, '参数非法', 'index.php');
      }
  } else {
      toMsgPage(2, '请先登录再进行该操作', 'login.php');
  }
